package org.example.domain.user_raffle.service.engine;

import org.example.domain.user_raffle.model.entity.ActivityStrategyPrizeEntity;
import org.example.domain.user_raffle.repository.IUserRaffleRepo;
import org.example.domain.user_raffle.service.engine.handler.BlackListHandler;
import org.example.domain.user_raffle.service.engine.handler.DefaultHandler;
import org.example.domain.user_raffle.service.engine.handler.GuaranteeHandler;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author lxc18
 * @date 2025/3/29 20:33
 * @description RaffleChain
 */
@Component
public class RaffleChainFactory {

    private final BlackListHandler blackListHandler;

    private final DefaultHandler defaultHandler;

    private final GuaranteeHandler guaranteeHandler;

    @Resource
    private IUserRaffleRepo userRaffleRepo;

    public RaffleChainFactory(BlackListHandler blackListHandler, DefaultHandler defaultHandler, GuaranteeHandler guaranteeHandler) {
        this.blackListHandler = blackListHandler;
        this.defaultHandler = defaultHandler;
        this.guaranteeHandler = guaranteeHandler;
    }
    @PostConstruct
    public void init(){
        blackListHandler.setNext(guaranteeHandler);
        guaranteeHandler.setNext(defaultHandler);
    }
    public List<Long> process(Long userId, Long activityId,int usedQuota,Map<String, ActivityStrategyPrizeEntity> allActivityStrategyPrizeEntity) {
        return blackListHandler.doHandler(userId, activityId,usedQuota,allActivityStrategyPrizeEntity);
    }

}
